/**
 * @created by anqi
 * @updated by
 * @description 单一客户视图
 */
define(['./custom/widgets/js/yufpSelectParam.js', 'echarts'],
    function(require, exports) {
        /**
         * 页面加载完成时触发
         * @param hashCode 路由ID
         * @param data 传递数据对象
         * @param cite 页面站点信息
         */
        exports.ready = function(hashCode, data, cite) {
            yufp.custom.vue({
                el: cite.el,
                data: function() {
                    return {
                        activeIndex: '2',
                        optionsB: [{
                            id: 1,
                            name: 'HKD'
                        }, {
                            id: 2,
                            name: 'HKD’K'
                        }, {
                            id: 3,
                            name: 'HKD’M'
                        }],
                        brand: {
                            'id': 3,
                            'name': '阿依莲'
                        },
                        //表格
                        tableData6: [{
                            id: '12987122',
                            name: '王小虎王小虎王小虎王小虎王小虎王小虎王小虎王小虎王小虎王小虎王小虎王小虎王小虎王小虎王小虎王小虎王小虎',
                            amount1: '234',
                            amount2: '3.2',
                            amount3: 10
                        }, {
                            id: '12987123',
                            name: '王小虎',
                            amount1: '165',
                            amount2: '4.43',
                            amount3: 12
                        }, {
                            id: '12987124',
                            name: '王小虎',
                            amount1: '324',
                            amount2: '1.9',
                            amount3: 9
                        }, {
                            id: '12987125',
                            name: '王小虎',
                            amount1: '621',
                            amount2: '2.2',
                            amount3: 17
                        }, {
                            id: '12987126',
                            name: '王小虎',
                            amount1: '539',
                            amount2: '4.1',
                            amount3: 15
                        }],
                        colo1: new echarts.graphic.LinearGradient(
                            0, 0, 0, 1, [
                                { offset: 0, color: '#67C7F9 ' },
                                { offset: 1, color: '#759AFD  ' }
                            ]
                        )
                    };
                },
                created() {
                    this.$nextTick(function() {
                        this.initChart();
                    });
                },
                methods: {
                    handleSelect: function(key, keyPath) {
                        this.activeIndex = key
                            // yufp.logger.info(key, keyPath);
                    },
                    selecbrandFn: function(val) {
                        console.log(val)
                            // 待引入this.$message({ message: val })
                    },
                    arraySpanMethod: function(obj) {
                        // 通过给table传入span - method方法可以实现合并行或列， 方法的参数是一个对象， 里面包含当前行row、 当前列column、 当前行号rowIndex、 当前列号columnIndex四个属性。 该函数可以返回一个包含两个元素的数组， 第一个元素代表rowspan， 第二个元素代表colspan。 也可以返回一个键名为rowspan和colspan的对象。
                    },
                    // Profitability 图表
                    initChart: function(data) {
                        let myChart = echarts.init(document.getElementById("barEchart"));
                        myChart.setOption(this.getBarOption(this.color1))
                    },
                    getBarOption(cl) {
                        return {
                            tooltip: {
                                trigger: 'axis',
                                axisPointer: { // 坐标轴指示器，坐标轴触发有效
                                    type: 'shadow' // 默认为直线，可选为：'line' | 'shadow'
                                }
                            },
                            legend: {
                                right: 20,
                                data: ['直接访问', '搜索引擎']
                            },
                            grid: {
                                left: '3%',
                                right: '4%',
                                bottom: '3%',
                                containLabel: true
                            },
                            xAxis: {
                                type: 'category',
                                axisTick: {
                                    show: false
                                },
                                axisLine: {
                                    show: false
                                },
                                data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
                            },
                            yAxis: {
                                type: 'value',
                                axisLine: {
                                    show: false
                                },
                                axisTick: {
                                    show: false
                                },
                            },
                            series: [{
                                    name: '搜索引擎',
                                    type: 'bar',
                                    stack: '总量',
                                    label: {
                                        show: true,
                                        position: 'insideRight'
                                    },

                                    itemStyle: {
                                        normal: {
                                            color: new echarts.graphic.LinearGradient(
                                                0, 0, 0, 1, [
                                                    { offset: 0, color: '#67C7F9 ' },
                                                    { offset: 1, color: '#759AFD  ' }
                                                ]
                                            )
                                        }


                                    },

                                    data: [820, 832, 901, 934, 1290, 1330, 1320]
                                },

                                {
                                    name: '直接访问',
                                    type: 'bar',
                                    stack: '总量',
                                    label: {
                                        show: true,
                                        position: 'insideRight'
                                    },
                                    itemStyle: {
                                        normal: {
                                            color: new echarts.graphic.LinearGradient(
                                                0, 0, 0, 1, [
                                                    { offset: 0, color: '#FFE06E ' },
                                                    { offset: 1, color: '#FFBB5A ' }

                                                ]
                                            )
                                        }
                                    },
                                    data: [320, 302, 301, 334, 390, 330, 320]
                                }

                            ]
                        }
                    },
                    mounted() {
                        this.$nextTick(function() {
                            this.initChart();
                        });
                    }

                }

            });
        };
    });